//
//  BSPasswordSettingView.m
//  SuoSiApp
//
//  Created by zhang on 16/4/15.
//  Copyright © 2016年 Ym. All rights reserved.
//

#import "BSPasswordSettingView.h"

@interface BSPasswordSettingView ()<UITextFieldDelegate>

@end

@implementation BSPasswordSettingView

- (instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];
    if (self) {
       [self setSubviews] ;
    }
    return self;
}

- (void)setSubviews{

    CGFloat Y = self.navigationView.bottom;
    self.titleLB = [self getLableWithFrameY:Y text:@" 密码设置"];
    self.titleLB.backgroundColor = [UIColor clearColor];
    
    self.originalPWLB = [self getLableWithFrameY:self.titleLB.bottom + 1 text:@" 原始密码"];
    self.ynewPWLB = [self getLableWithFrameY:self.originalPWLB.bottom + 1 text:@" 新密码"];
    self.confirmPWLB = [self getLableWithFrameY:self.ynewPWLB.bottom + 1 text:@" 确认密码"];
    CGFloat TFY = self.originalPWLB.top;
   self.originalPWTF = [self makeTextfeildWithFrameY:TFY placeHolder:@" 请输入原始密码"];
    self.originalPWTF.secureTextEntry = YES;
    self.originalPWTF.tag = 501;
    
   self.ynewPWTF = [self makeTextfeildWithFrameY:self.ynewPWLB.top placeHolder:@" 请输入新密码"];
    self.ynewPWTF.tag = 501;
    self.ynewPWTF.secureTextEntry = YES;
    self.confirmPWTF = [self makeTextfeildWithFrameY:self.confirmPWLB.top placeHolder:@" 请确认密码"];
    self.confirmPWTF.secureTextEntry = YES;
    self.confirmPWTF.tag = 501;
    [self.scrollView removeFromSuperview];
    
    self.saveBT.top = self.confirmPWLB.bottom +kMartin40;
    

}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (UILabel *)getLableWithFrameY:(CGFloat)Y text:(NSString *)text{
    
    CGRect frame = CGRectMake(0, Y, kScrenWidth*3/8 , 43);
    UILabel *lable = [[UILabel alloc]initWithFrame:frame];
    lable.text = text;
    lable.font = [UIFont systemFontOfSize:20];
    lable.backgroundColor = BSWhite;
    [self addSubview:lable];
    return lable;
}
- (UITextField *)makeTextfeildWithFrameY:(CGFloat)YTF placeHolder:(NSString *)text{
    
    UITextField *textFeild = [[UITextField alloc]initWithFrame:CGRectMake(kScrenWidth*3/8 - 1, YTF, kScrenWidth *5/8 , 43)];
    textFeild.delegate = self;;
    textFeild.placeholder = text;
    textFeild.backgroundColor = BSWhite;
    
//    
//    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(textFeild.right - kMartin10, textFeild.top, kMartin10, textFeild.height)];
//    lable.backgroundColor = BSWhite;
//    textFeild.rightViewMode = UITextFieldViewModeAlways;
//    
//    textFeild.rightView = lable;
    
    textFeild.textAlignment = NSTextAlignmentLeft;
    textFeild.font = [UIFont systemFontOfSize:20];
    textFeild.borderStyle = UITextBorderStyleNone;
    [self addSubview:textFeild];
    return textFeild;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [textField resignFirstResponder];
    return YES;
}

@end
